home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UCRASM25.ARJ / TESTPFF.ASM < prev    next >
Assembly Source File  |  1991-11-08  |  8KB  |  321 lines

  1.         include        stdlib.a
  2.         includelib     stdlib.lib
  3. ;****************************************************************************
  4. ;
  5. ; T  E  S  T       S  U  I  T  E      F  O  R
  6. ;
  7. ;
  8. ; R  A  N  D  Y      H  Y  D  E ' S     S  T  A  N  D  A  R  D
  9. ;
  10. ; L  I  B  R  A  R  Y     F  O  R     A  S  S  E  M  B  L  Y
  11. ;
  12. ; L  A  N  G  U  A  G  E     P  R  O  G  R  A  M  M  E  R  S
  13. ;
  14. ;
  15. ; PRINTFF Routine
  16. ;
  17. ;****************************************************************************
  18. ;
  19. ;
  20. ; Global variables go here:
  21. ;
  22. StdData        segment    para public 'sldata'
  23.         extrn    fpacc:byte
  24. StdData        ends
  25. ;
  26. ;
  27. dseg        segment    para public 'data'
  28. i        dw    -4321
  29. pi        dd    i
  30. u        dw    2345
  31. pu        dd    u
  32. l        dd    -1234567890
  33. pl        dd    l
  34. ul        dd    987654321
  35. pul        dd    ul
  36. ;
  37. ps        dd    s
  38. s        db    "printff string",0
  39. MemAvail    dw    ?
  40. ;
  41. ;
  42. ;
  43. ;
  44. ; Floating point values:
  45. ;
  46. SPConst1    dd    1.0
  47. SPConst10    dd    10.25
  48. SPConst100    dd    100.50
  49. SPConst1000    dd    1000.75
  50. ;
  51. DPConst1    dq    1.0
  52. DPConst10    dq    10.25
  53. DPConst100    dq    100.50
  54. DPConst1000    dq    1000.75
  55. ;
  56. EPConst1    dt    1.0
  57. EPConst10    dt    10.25
  58. EPConst100    dt    100.50
  59. EPConst1000    dt    1000.75
  60. ;
  61. ;
  62. ;
  63. dseg        ends
  64. ;
  65. ;
  66. ;
  67. ;
  68. cseg        segment    para public 'code'
  69.         assume    cs:cseg, ds:dseg
  70. ;
  71. ;
  72. lesi        macro    adrs
  73.         mov     di, seg adrs
  74.         mov    es, di
  75.         lea    di, adrs
  76.         endm
  77. ;
  78. ldxi        macro    adrs
  79.         mov    dx, seg adrs
  80.         lea    si, adrs
  81.         endm
  82. ;
  83. ; Variables that wind up being used by the standard library routines.
  84. ; The MemInit routine uses "PSP" and "zzzzzzseg" labels.  They must be
  85. ; present if you intend to use getenv, MemInit, malloc, and free.
  86. ;
  87. ;
  88.         public    PSP
  89. PSP        dw    ?
  90. ;
  91. cr        equ    13
  92. lf        equ    10
  93. ;
  94. ;
  95. ; Main is the main program.  Program execution always begins here.
  96. ;
  97. Main        proc
  98.         mov    cs:PSP, es        ;Save pgm seg prefix
  99.         mov    ax, seg dseg        ;Set up the segment registers
  100.         mov    ds, ax
  101.         mov    es, ax
  102.         mov    dx, 0            ;Allocate all available RAM.
  103.         MemInit
  104.         mov    MemAvail, cx
  105.         printff
  106.         db    "There are %x paragraphs of memory available."
  107.         db    cr,lf,lf,0
  108.         dd    MemAvail
  109. ;
  110. ;
  111. ;****************************************************************************
  112. ;
  113. ; Testing the printffF routine:
  114. ;
  115.         printff
  116.         db    "This is a test of the printff routine w/o any "
  117.         db    "operands.\n"
  118.         db    "It tests the esc characters \\n, \\r, \\b, \\t, "
  119.         db    "\0x0d, and \\\\.\n"
  120.         db    "Test of \\r:\n"
  121.         db    "Old line.\rNew line.\n"
  122.         db    "Test of \t\ttab.\n"
  123.         db    "Test of backspace\b\b\b\b\bs p a c e\n"
  124.         db    "Test of return using \\0x0d:\n"
  125.         db    "Old line.\0x0dNew line.\n\n",0
  126. ;
  127.         printff
  128.         db    cr,lf
  129.         db    "Test of integer output formats (using I):\n"
  130.         db    "\%d\t\t-\t*%d*\n"
  131.         db    "\%10d\t\t-\t*%10d*\n"
  132.         db    "\%-10d\t\t-\t*%-10d*\n"
  133.         db    "\%\\*10d\t\t-\t*%\*10d*\n"
  134.         db    "\%\-\\*10d\t\t-\t*%-\*10d*\n"
  135.         db    "\%^d\t\t-\t*%^d*\n"
  136.         db    "\%10^d\t\t-\t*%10^d*\n"
  137.         db    "\%-10^d\t\t-\t*%-10^d*\n"
  138.         db    "\%\\*10^d\t\t-\t*%\*10^d*\n"
  139.         db    "\%\-\\*10^d\t-\t*%-\*10^d*\n"
  140.         db    0
  141.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  142. ;
  143.         printff
  144.         db    cr,lf
  145.         db    "Test of unsigned integer output formats (using U):\n"
  146.         db    "\%u\t\t-\t*%u*\n"
  147.         db    "\%10u\t\t-\t*%10u*\n"
  148.         db    "\%-10u\t\t-\t*%-10u*\n"
  149.         db    "\%\\*10u\t\t-\t*%\*10u*\n"
  150.         db    "\%\-\\*10u\t\t-\t*%-\*10u*\n"
  151.         db    "\%^u\t\t-\t*%^u*\n"
  152.         db    "\%10^u\t\t-\t*%10^u*\n"
  153.         db    "\%-10^u\t\t-\t*%-10^u*\n"
  154.         db    "\%\\*10^u\t\t-\t*%\*10^u*\n"
  155.         db    "\%\-\\*10^u\t-\t*%-\*10^u*\n"
  156.         db    0
  157.         dd    u,u,u,u,u,pu,pu,pu,pu,pu
  158. ;
  159.         printff
  160.         db    cr,lf
  161.         db    "Test of unsigned long output formats (using UL):\n"
  162.         db    "\%ul\t\t-\t*%lu*\n"
  163.         db    "\%15lu\t\t-\t*%15lu*\n"
  164.         db    "\%-15lu\t\t-\t*%-15lu*\n"
  165.         db    "\%\\*15lu\t\t-\t*%\*15lu*\n"
  166.         db    "\%\-\\*15lu\t-\t*%-\*15lu*\n"
  167.         db    "\%^lu\t\t-\t*%^lu*\n"
  168.         db    "\%15^lu\t\t-\t*%15^lu*\n"
  169.         db    "\%-15^lu\t\t-\t*%-15^lu*\n"
  170.         db    "\%\\*15^lu\t-\t*%\*15^lu*\n"
  171.         db    "\%\-\\*15^lu\t-\t*%-\*15^lu*\n"
  172.         db    0
  173.         dd    ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
  174. ;
  175.         printff
  176.         db    cr,lf
  177.         db    "Test of long output formats (using L):\n"
  178.         db    "\%ld\t\t-\t*%ld*\n"
  179.         db    "\%15ld\t\t-\t*%15ld*\n"
  180.         db    "\%-15ld\t\t-\t*%-15ld*\n"
  181.         db    "\%\\*15ld\t\t-\t*%\*15ld*\n"
  182.         db    "\%\-\\*15ld\t-\t*%-\*1ld*\n"
  183.         db    "\%^ld\t\t-\t*%^ld*\n"
  184.         db    "\%15^ld\t\t-\t*%15^ld*\n"
  185.         db    "\%-15^ld\t\t-\t*%-15^ld*\n"
  186.         db    "\%\\*15^ld\t-\t*%\*15^ld*\n"
  187.         db    "\%\-\\*15^ld\t-\t*%-\*15^ld*\n"
  188.         db    0
  189.         dd    l,l,l,l,l,pl,pl,pl,pl,pl
  190. ;
  191.         printff
  192.         db    cr,lf
  193.         db    "Test of hexadecimal output (byte) using I:\n"
  194.         db    "\%h\t\t-\t*%h*\n"
  195.         db    "\%5h\t\t-\t*%5h*\n"
  196.         db    "\%-5h\t\t-\t*%-5h*\n"
  197.         db    "\%\\*5h\t\t-\t*%\*5h*\n"
  198.         db    "\%\-\\*5h\t\t-\t*%-\*5h*\n"
  199.         db    "\%^h\t\t-\t*%^h*\n"
  200.         db    "\%5^h\t\t-\t*%5^h*\n"
  201.         db    "\%-5^h\t\t-\t*%-5^h*\n"
  202.         db    "\%\\*5^h\t\t-\t*%\*5^h*\n"
  203.         db    "\%\-\\*5^h\t\t-\t*%-\*5^h*\n"
  204.         db    0
  205.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  206. ;
  207.         printff
  208.         db    cr,lf
  209.         db    "Test of hexadecimal output (word) using I:\n"
  210.         db    "\%x\t\t-\t*%x*\n"
  211.         db    "\%5x\t\t-\t*%5x*\n"
  212.         db    "\%-5x\t\t-\t*%-5x*\n"
  213.         db    "\%\\*5x\t\t-\t*%\*5x*\n"
  214.         db    "\%\-\\*5x\t\t-\t*%-\*5x*\n"
  215.         db    "\%^x\t\t-\t*%^x*\n"
  216.         db    "\%5^x\t\t-\t*%5^x*\n"
  217.         db    "\%-5^x\t\t-\t*%-5^x*\n"
  218.         db    "\%\\*5^x\t\t-\t*%\*5^x*\n"
  219.         db    "\%\-\\*5^x\t\t-\t*%-\*5^x*\n"
  220.         db    0
  221.         dd    i,i,i,i,i,pi,pi,pi,pi,pi
  222. ;
  223.         printff
  224.         db    cr,lf
  225.         db    "Test of hexadecimal output (long) using UL:\n"
  226.         db    "\%lx\t\t-\t*%lx*\n"
  227.         db    "\%15lx\t\t-\t*%15lx*\n"
  228.         db    "\%-15lx\t\t-\t*%-15lx*\n"
  229.         db    "\%\\*15lx\t\t-\t*%\*15lx*\n"
  230.         db    "\%\-\\*15lx\t-\t*%-\*15lx*\n"
  231.         db    "\%^lx\t\t-\t*%^lx*\n"
  232.         db    "\%15^lx\t\t-\t*%15^lx*\n"
  233.         db    "\%-15^lx\t\t-\t*%-15^lx*\n"
  234.         db    "\%\\*15^lx\t-\t*%\*15^lx*\n"
  235.         db    "\%\-\\*15^lx\t-\t*%-\*15^lx*\n"
  236.         db    0
  237.         dd    ul,ul,ul,ul,ul,pul,pul,pul,pul,pul
  238. ;
  239.         printff
  240.         db    cr,lf
  241.         db    "Test of character output using S:\n"
  242.         db    "\%c\t\t-\t*%c*\n"
  243.         db    "\%5c\t\t-\t*%5c*\n"
  244.         db    "\%-5c\t\t-\t*%-5c*\n"
  245.         db    "\%\\*5c\t\t-\t*%\*5c*\n"
  246.         db    "\%\-\\*5c\t\t-\t*%-\*5c*\n"
  247.         db    "\%^c\t\t-\t*%^c*\n"
  248.         db    "\%5^c\t\t-\t*%5^c*\n"
  249.         db    "\%-5^c\t\t-\t*%-5^c*\n"
  250.         db    "\%\\*5^c\t\t-\t*%\*5^c*\n"
  251.         db    "\%\-\\*5^c\t\t-\t*%-\*5^c*\n"
  252.         db    0
  253.         dd    s,s,s,s,s,ps,ps,ps,ps,ps
  254. ;
  255.         printff
  256.         db    cr,lf
  257.         db    "Test of string output using s:\n"
  258.         db    "\%s\t\t-\t*%s*\n"
  259.         db    "\%15s\t\t-\t*%15s*\n"
  260.         db    "\%-15s\t\t-\t*%-15s*\n"
  261.         db    "\%\\*15s\t\t-\t*%\*15s*\n"
  262.         db    "\%\-\\*15s\t\t-\t*%-\*15s*\n"
  263.         db    "\%^s\t\t-\t*%^s*\n"
  264.         db    "\%15^s\t\t-\t*%15^s*\n"
  265.         db    "\%-15^s\t\t-\t*%-15^s*\n"
  266.         db    "\%\\*15^s\t\t-\t*%\*15^s*\n"
  267.         db    "\%\-\\*15^s\t-\t*%-\*15^s*\n"
  268.         db    0
  269.         dd    s,s,s,s,s,ps,ps,ps,ps,ps
  270. ;
  271.         printff
  272.         db    "Testing printff floating point output",cr,lf
  273.         db    "SP:    1.00 = %7.2f  %12e",cr,lf
  274.         db    "SP:   10.25 = %7.2f  %12e",cr,lf
  275.         db    "SP:  100.50 = %7.2f  %12e",cr,lf
  276.         db    "SP: 1000.75 = %7.2f  %12e",cr,lf
  277.         db    "DP:    1.00 = %7.2gf  %12ge",cr,lf
  278.         db    "DP:   10.25 = %7.2gf  %12ge",cr,lf
  279.         db    "DP:  100.50 = %7.2gf  %12ge",cr,lf
  280.         db    "DP: 1000.75 = %7.2gf  %12ge",cr,lf
  281.         db    "EP:    1.00 = %7.2lf  %13le",cr,lf
  282.         db    "EP:   10.25 = %9.3lf  %14le",cr,lf
  283.         db    "EP:  100.50 = %11.4lf  %15le",cr,lf
  284.         db    "EP: 1000.75 = %13.5lf  %16le",cr,lf
  285.         db    0
  286.         dd      SPConst1, SPConst1, SPConst10, SPConst10
  287.         dd    SPConst100, SPConst100, SPConst1000, SPConst1000
  288.         dd      DPConst1, DPConst1, DPConst10, DPConst10
  289.         dd    DPConst100, DPConst100, DPConst1000, DPConst1000
  290.         dd      EPConst1, EPConst1, EPConst10, EPConst10
  291.         dd    EPConst100, EPConst100, EPConst1000, EPConst1000
  292. ;
  293. ;
  294. Quit:        mov     ah, 4ch
  295.         int     21h
  296. ;
  297. ;
  298. Main        endp
  299. ;
  300. ;
  301. ;
  302. ;
  303. cseg            ends
  304. ;
  305. ;
  306. ; Allocate a reasonable amount of space for the stack (2k).
  307. ;
  308. sseg        segment    para stack 'stack'
  309. stk        db    256 dup ("stack   ")
  310. sseg        ends
  311. ;
  312. ;
  313. ;
  314. ; zzzzzzseg must be the last segment that gets loaded into memory!
  315. ;
  316. zzzzzzseg    segment    para public 'zzzzzz'
  317. LastBytes    db    16 dup (?)
  318. heap        db    1024 dup (?)
  319. zzzzzzseg    ends
  320.         end    Main
  321.